package com.cartagena.financo.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.SessionScoped;

import com.cartagena.financo.model.Term;
import com.cartagena.ofx.model.OFXTransaction;

@Component
@SessionScoped
public class FloatingOFXTransactions {
    
    private List<OFXTransaction> transactions;
    private Set<Term> newterms;
    
    public FloatingOFXTransactions() {
        transactions = new ArrayList<OFXTransaction>();
    }
    
    public List<OFXTransaction> getTransactions(String description) {
        List<OFXTransaction> trans = new ArrayList<OFXTransaction>();
        for(OFXTransaction ofx : transactions) {
            if(ofx.getDescription().equalsIgnoreCase(description)) {
                trans.add(ofx);
            }
        }
        
        return trans;
    }
    
    public void remove(List<OFXTransaction> remove) {
        transactions.removeAll(remove);
    }

    public List<OFXTransaction> getTransactions() {
        return transactions;
    }

    public void setTransactions(List<OFXTransaction> transactions) {
        this.transactions = transactions;
    }

    public Set<Term> getNewterms() {
        return newterms;
    }

    public void setNewterms(Set<Term> newterms) {
        this.newterms = newterms;
    }

}
